/**
 *  JSimProd - Java simulation code for production processes
 *  Copyleft Jorge Mira Yagüe <jorge.mira.yague@gmail.com>
 *  Universidad de Alicante 2009
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package gui.tools;

/**
 * This class represents a bar with its coordenates and a name
 * @author Jorge Mira Yagüe
 */
public class Bar {

    private int x;
    private int y;
    private int width;
    private int height;
    private String name;

    public Bar(int x, int y, int width, int height, String name) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.name = name;
    }

    /**
     * This function returns the value of the name if the coordenates given are
     * inside of the bar and null otherwise
     * @param x X coordinate
     * @param y Y Coordinate
     * @return The name of the bar
     */
    public String contains(int x, int y) {
        if (this.x <= x && (this.x + width) >= x && this.y <= y && (this.y + height) >= y) {
            return name;
        } else {
            return null;
        }
    }
}
